

export const MENUS = [
	{title: '用户管理', path: '/user'},
	{title: '文章管理', path: '/article', children: [
		{title: '文章编辑', path: '/article/data'},
		{title: '文章详情', path: '/article/info'}
	]},
]


// 获取当前路由的宗族路由
export function getClanRoutes(menus, path) {
	let res = null;
	ergodic(menus, []);
	return res;

	// 遍历
	function ergodic(arr, parent) {
		for (let i = 0; i < arr.length; i++) {
			let item = arr[i];
			let obj = {};
			for (let key in item) {
				if(key != 'children') {
					obj[key] = item[key];
				}
			}
			let aClan = [...parent, obj];
			if (item.path == path) {
				res = aClan;
			}
			if (res) {
				break;
			}
			if(item.children) {
				ergodic(item.children, aClan);
			}
		}
	}
}

